home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / DESK / CORE / Desk / h_doc / Print < prev    next >
Text File  |  1996-05-21  |  4KB  |  128 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Print.h
  12.     Author:  Copyright © 1995 Julian Smith
  13.     Version: 1.00 (20 Jan 1995)
  14.     Purpose: Automatic handling of RO 3 wimp printing protocol messages, 
  15.              and some of the PDriver calls involved in printing.
  16.  
  17. */
  18.  
  19. #ifndef __Desk_Print_h
  20. #define __Desk_Print_h
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26. #ifndef __Desk_Wimp_h
  27.     #include "Desk.Wimp.h"
  28. #endif
  29.  
  30.  
  31. #ifndef __Desk_PDriver_h
  32.     #include "Desk.PDriver.h"
  33. #endif
  34.  
  35.  
  36.  
  37.  
  38. typedef struct Desk_print_block    {
  39.     void        *reference;    /* As passed to Desk_Print_StartPrint.    */
  40.     char        *jobtitle;    /* As passed to Desk_Print_StartPrint.    */
  41.     Desk_printer_info    printerinfo;    /* This info may be useful to printfn.    */
  42.     Desk_print_job    job;        /* The current job handle.        */
  43.     Desk_print_job    oldjob;        /* The previous job (if any).        */
  44.     }
  45.     Desk_print_block;
  46.  
  47.  
  48. enum    {
  49.     Desk_print_result_OK        = 0,     /* Printing is finished.            */
  50.     Desk_print_result_QUEUED,         /* Data has been saved into printer queue.    */
  51.     Desk_print_result_NEEDPRINTERMANAGER, /* printfn==NULL, but !Printers not running.    */
  52.     Desk_print_result_PRINTERROR,     /* Desk_message_PRINTERROR received.            */
  53.     Desk_print_result_SAVEFAILED,     /* savefn failed.                */
  54.     Desk_print_result_CANTSAVE,         /* savefn==NULL, !Printers busy            */
  55.     Desk_print_result_CANTOPENPRINTER,     /* Desk_File_Open( "Printer:") failed.        */
  56.     Desk_print_result_FAILED        /* Something else has gone wrong.        */
  57.     };
  58.  
  59. typedef int    Desk_print_result;
  60.     /* If result>255, it is an (Desk_os_error *), otherwise it is a Desk_print_result_*    */
  61.  
  62.  
  63.  
  64. typedef Desk_bool (*Desk_print_printfn)( Desk_print_block *print);
  65. typedef Desk_bool (*Desk_print_savefn)( Desk_print_block *print, Desk_message_datasaveack *datasaveack);
  66. typedef void (*Desk_print_resultfn)( Desk_print_block *print, Desk_print_result result);
  67.  
  68.  
  69.  
  70. void    Desk_Print_StartPrint( 
  71.         Desk_print_printfn    printfn,     /* Called to do the actual printing after    */
  72.                         /* the wimp messageing has finished.        */
  73.         Desk_print_savefn    savefn,         /* Called if print job is queued.        */
  74.         Desk_print_resultfn    resulfn,     /* Always called.                */
  75.         void        *reference,     /* Always passed to the above functions.    */
  76.         int        filetype,     /* Used if print data is saved in queue.    */
  77.         int        estsize,     /* Used if print data is saved in queue.    */
  78.         char        *leafname,     /* Used if print data is saved in queue.    */
  79.         char        *jobtitle
  80.         );
  81. /*
  82.  
  83. Call this function to start a printout. Desk_Print_StartPrint does all the
  84. wimp message handling needed to start a print job, sets up the printer
  85. driver and then calls 'printfn'.
  86.  
  87. Returns NOERROR if the print protocol was started ok. Otherwise returns
  88. ERROR.
  89.  
  90. Note that 'jobtitle' is *not* strcpy-ed, so the string must be present
  91. until printing has finished.
  92.  
  93. 'printfn' should print the data. 'savefn' should save the data to a file
  94. in a form that can be printed later - this is done if the print job
  95. needs to be queued.
  96.  
  97. Both 'printfn' and 'savefn' should return ERROR or NOERROR (see
  98. DeskLib:Core.h).
  99.  
  100. 'resultfn' will always be called with the result of the print.
  101.  
  102. Pass NULL for printfn or savefn if you can't print directly or can't
  103. save the data to a file. Obviously, if both printfn and savefn are NULL,
  104. the print will fail.
  105.  
  106. 'savefn' will be called if !Printers already has a queue, or if
  107. 'printfn'==NULL. In this case, !Printers prints the file itself when it
  108. comes to top of printer queue if it can (eg a text file), else it
  109. broadcasts Desk_message_PRINTTYPEODD. You should register an event handler
  110. for Desk_message_PRINTTYPEODD if resultfn is told that the job has been
  111. queued *and* savefn has saved the data in a non-standard format that
  112. !Printers won't be able to print itself.
  113.  
  114. 'printfn' will be called if !Printers is not running but there is a
  115. printer driver loaded, or if !Printers has no queue of print jobs.
  116.  
  117. 'resultfn' is always called, with a Desk_print_result. If greater than
  118. 256, it is an (Desk_os_error *) from a PDriver SWi.
  119.  
  120. */
  121.  
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125.  
  126.  
  127. #endif
  128.